package test.maven;

import java.util.Map;

import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
import com.jfinal.plugin.druid.DruidPlugin;

public class LicaiKey {
	
	public static void main(String[] args) {
		DruidPlugin dp = new DruidPlugin("jdbc:mysql://192.168.2.14/licai?characterEncoding=UTF-8", "root", "123456");
		ActiveRecordPlugin arp = new ActiveRecordPlugin(dp);
		arp.setDevMode(true);
		arp.setShowSql(true);
		arp.addMapping("lc_platform_api", "platform_id", PlatformApi.class);
		dp.start();
		arp.start();
		
		Map<String, Object> map1 = RSAUtil.genKeyPair();
		String sprivatekey = RSAUtil.getPrivateKey(map1);
		String cpublickey = RSAUtil.getPublicKey(map1);
		Map<String, Object> map2 = RSAUtil.genKeyPair();
		String cprivatekey = RSAUtil.getPrivateKey(map2);
		String spublickey = RSAUtil.getPublicKey(map2);
		
		PlatformApi api = new PlatformApi();
		api.set("platformcode", "gscf");
		api.set("sprivatekey", sprivatekey);
		api.set("cpublickey", cpublickey);
		api.set("cprivatekey", cprivatekey);
		api.set("spublickey", spublickey);
		api.save();
	}

}
